/**
 * @Author Stringzhua
 * @Date 2024/11/1 11:30
 * description:在父子线程之间传递数据
 */
public class Demo02 {
    public static void main(String[] args) {
//        ThreadLocal<String> threadLocal = new ThreadLocal<>();
        InheritableThreadLocal<String> threadLocal = new InheritableThreadLocal<>();
        threadLocal.set("一猫人");

        System.out.println("主线程" + threadLocal.get());

        Thread t1 = new Thread(new Runnable() {
            @Override
            public void run() {
                String s = threadLocal.get();
                System.out.println(Thread.currentThread().getName() + s);
            }
        }, "子线程");
        t1.start();

    }
}
